package com.huike.business.service.impl;


import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商机跟进记录Service业务层处理
 * 
 * @author wgl
 * @date 2021-04-28
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {
    @Autowired
private TbBusinessTrackRecordMapper businessTrackRecordMapper;
    @Override
    public Integer addBusinessTrack(BusinessTrackVo businessTrackVo) {
        TbBusinessTrackRecord tbBusinessTrackRecord = new TbBusinessTrackRecord();
        // 1 商机ID
        tbBusinessTrackRecord.setBusinessId(businessTrackVo.getBusinessId());
        // 2 沟通纪要
        tbBusinessTrackRecord.setRecord(businessTrackVo.getRecord());
        // 3 沟通重点
        tbBusinessTrackRecord.setKeyItems(businessTrackVo.getKeyItems());
        // 4 下次跟进时间
        tbBusinessTrackRecord.setNextTime(businessTrackVo.getNextTime());
        // 5 创建时间
        tbBusinessTrackRecord.setCreateTime(DateUtils.getNowDate());
        // 6 创建者
        tbBusinessTrackRecord.setCreateBy(SecurityUtils.getUsername());
        // 7 跟进状态
        tbBusinessTrackRecord.setTrackStatus(businessTrackVo.getTrackStatus());




       Integer rows = businessTrackRecordMapper.addBusinessTrack(tbBusinessTrackRecord);
        return rows;
    }

    @Override
    public List<TbBusinessTrackRecord> selectBusinessTrack(Long id) {
        List<TbBusinessTrackRecord> businessTrackRecords = businessTrackRecordMapper.selectBusinessTrack(id);
        return businessTrackRecords;
    }
}
